<template>
    <el-row>
        <el-form :model="reviewrSearchObj"
            label-width="120px"
            class="search_prod">
            <el-form-item label="用户昵称">
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            v-model="reviewrSearchObj.username"
                            placeholder="用户昵称"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">会员账号&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            v-model="reviewrSearchObj.uid"
                            placeholder="会员账号"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">商品名称&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            v-model="reviewrSearchObj.pid_cn"
                            placeholder="商品名称"></el-input>
                    </el-col>
                </el-col>
            </el-form-item>
            <el-form-item label="商品ID">
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            v-model="reviewrSearchObj.pid"
                            placeholder="商品ID"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">评价内容&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            v-model="reviewrSearchObj.content"
                            placeholder="评价内容"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">是否审核&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-select v-model="reviewrSearchObj.is_check"
                            clearable
                            size="small"
                            placeholder="审核状态">
                            <el-option v-for="item in is_checkList"
                                size="small"
                                :key="item.id"
                                :label="item.title"
                                :value="item.id">
                            </el-option>
                        </el-select>
                    </el-col>
                </el-col>
            </el-form-item>
            <el-form-item label="时间">
                <el-col :span="5">
                    <el-col :span="22"
                        class="search_time_width">
                        <el-date-picker style="width:100%"
                            v-model="createTime"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>
                </el-col>
            </el-form-item>
            <el-form-item>
                <el-row class="tl">
                    <el-col :span="24">
                        <el-button :loading='$store.state.isLoading'
                            size="small"
                            type="primary"
                            @click="onSubmit">查询</el-button>
                        <el-button :loading='$store.state.isLoading'
                            size="small"
                            type="primary"
                            @click="delSubmit">一键清除</el-button>
                    </el-col>
                </el-row>
            </el-form-item>
        </el-form>
    </el-row>
</template>
<script>
export default {
  name: "productSearch",
  data() {
    return {
      pickerOptions2: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      is_checkList: [{ id: 0, title: "未审核" }, { id: 1, title: "已审核" }],
      createTime: [],
      reviewrSearchObj: {
        username: "",
        uid: "",
        pid_cn: "",
        pid: "",
        content: "",
        is_check: "",
        created_time_begin: "",
        created_time_end: ""
      }
    };
  },
  methods: {
    delSubmit() {
      this.reviewrSearchObj = {
        username: "",
        uid: "",
        pid_cn: "",
        pid: "",
        content: "",
        is_check: "",
        created_time_begin: "",
        created_time_end: ""
      };
      this.$emit("sendSearch", this.reviewrSearchObj);
    },
    onSubmit() {
      this.$emit("sendSearch", this.reviewrSearchObj);
    }
  },
  created() {},
  watch: {
    createTime(val) {
      if (val != null) {
        this.reviewrSearchObj.created_time_begin = this.$fnc.phptime(val[0]);
        this.reviewrSearchObj.created_time_end = this.$fnc.phptime(val[1]);
      } else {
        this.reviewrSearchObj.created_time_begin = "";
        this.reviewrSearchObj.created_time_end = "";
      }
    }
  }
};
</script>
